﻿using System.Drawing;
using System.Windows.Forms;

namespace NetTrafficStatistics
{
	class ListBoxMenu : ListBox
	{
		public ListBoxMenu ()
		{
			SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
            DrawMode = DrawMode.OwnerDrawFixed;
		}
		
		
		protected override void OnDrawItem (DrawItemEventArgs e)
		{
			string str = (string) Items[e.Index];
			StringFormat sf = new StringFormat
			{
				Alignment = MultiColumn ? StringAlignment.Center : StringAlignment.Near
			};

			if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))
			{
				e.Graphics.FillRectangle (new SolidBrush (Color.FromArgb (224, 224, 224)), e.Bounds);
				e.Graphics.DrawString (str, e.Font, new SolidBrush (Color.Gray), e.Bounds, sf);
			}
			else
			{
				e.Graphics.FillRectangle (new SolidBrush (Color.LightSteelBlue), e.Bounds);
				e.Graphics.DrawString (str, e.Font, new SolidBrush (Color.White), e.Bounds, sf);
			}
			e.DrawFocusRectangle ();
		}
	}
}